"""
用来存放类
"""

import datetime
from db import db_handler


class Base:

    def __init__(self, name):

        self.name = name
        self.register_date = datetime.datetime.now()
        self.save()

    # 调用数据处理层函数保存数据
    def save(self):
        db_handler.save_data(self)

    # 调用数据处理层函数查询数据
    @classmethod
    def select(cls, name):
        obj = db_handler.select_data(cls, name)
        return obj


class Admin(Base):

    def __init__(self, name, password):

        self.password = password

        # 累计付费人次
        self.pay_num = 0
        # 今日营收
        self.today_income = {}
        # 累计营收
        self.total_income = 0

        # 流水
        self.flow = []

        self.locked = False

        super().__init__(name)


class Student(Base):

    def __init__(self, name, password):

        self.password = password
        self.locked = False
        self.course_list = []
        self.learned_course_list = []

        super().__init__(name)


class Teacher(Base):
    pass


class School(Base):
    pass


class Course(Base):
    pass
